<?php

/**
 * Fixture form.
 *
 * @package    prode
 * @subpackage form
 * @author     Your name here
 */
class FixtureForm extends BaseFixtureForm
{
  public function configure()
  {
    $this->validatorSchema['anho'] = new sfValidatorNumber(
            array('min'=>date('Y'),'max'=>date('Y')+1)
    );
    $this->validatorSchema['fechanro'] = new sfValidatorNumber(
            array('min'=>1,'max'=>50)
    );
  }
  public function isValid(){
      // $log = sfContext::getInstance( )->getLogger( );
      $criteria = new Criteria;
      $criteria->add(FixturePeer::ANHO,$this['anho']->getValue());
      $criteria->add(FixturePeer::TORNEO_ID,$this['torneo_id']->getValue());
      $criteria->add(FixturePeer::TEMPORADA_ID,$this['temporada_id']->getValue());
      $criteria->add(FixturePeer::FECHANRO,$this['fechanro']->getValue());
      //$log->debug( "Se Ejecuto Mi codigo de Criteria jjj ".date('h:i:s') );
      if($fixture = FixturePeer::doSelectOne($criteria)){
        if ($fixture->getId() <> $this['id']->getValue()){
            //$this->errorSchema =  new sfValidatorErrorSchema();
            return false;
            
        }
        else
            return parent::isValid() ;

      }
      else
         return parent::isValid() ;
  }
}
